package com.ruoyi.order.service.impl;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.Product;
import com.ruoyi.order.domain.Vo.ProductVo;
import com.ruoyi.order.domain.app.Vo.ProductViewVo;
import com.ruoyi.order.mapper.ProductMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.HotProductMapper;
import com.ruoyi.order.domain.HotProduct;
import com.ruoyi.order.service.IHotProductService;
import com.ruoyi.common.core.text.Convert;

import javax.annotation.Resource;

/**
 * 热销产品Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-02-04
 */
@Service
public class HotProductServiceImpl implements IHotProductService 
{
    @Resource
    private HotProductMapper hotProductMapper;

    @Resource
    private ProductMapper productMapper;
    /**
     * 查询热销产品
     * 
     * @param id 热销产品主键
     * @return 热销产品
     */
    @Override
    public HotProduct selectHotProductById(Integer id)
    {
        return hotProductMapper.selectHotProductById(id);
    }

    /**
     * 查询热销产品列表
     * 
     * @param hotProduct 热销产品
     * @return 热销产品
     */
    @Override
    public List<HotProduct> selectHotProductList(HotProduct hotProduct)
    {
        return hotProductMapper.selectHotProductList(hotProduct);
    }

    /**
     * 新增热销产品
     * 
     * @param hotProduct 热销产品
     * @return 结果
     */
    @Override
    public int insertHotProduct(HotProduct hotProduct)
    {
        hotProduct.setCreateTime(DateUtils.getNowDate());
        return hotProductMapper.insertHotProduct(hotProduct);
    }

    /**
     * 修改热销产品
     * 
     * @param hotProduct 热销产品
     * @return 结果
     */
    @Override
    public int updateHotProduct(HotProduct hotProduct)
    {
        hotProduct.setUpdateTime(DateUtils.getNowDate());
        return hotProductMapper.updateHotProduct(hotProduct);
    }

    /**
     * 批量删除热销产品
     * 
     * @param ids 需要删除的热销产品主键
     * @return 结果
     */
    @Override
    public int deleteHotProductByIds(String ids)
    {
        return hotProductMapper.deleteHotProductByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除热销产品信息
     * 
     * @param id 热销产品主键
     * @return 结果
     */
    @Override
    public int deleteHotProductById(Integer id)
    {
        return hotProductMapper.deleteHotProductById(id);
    }

    @Override
    public List<ProductVo> getHotProductPage(String productName) {
        Map<String,Object> map = new HashMap<>();
        map.put("productName" , productName);
        map.put("state" , 0 );
        List<ProductVo> list = hotProductMapper.getHotProductPage(map);

        return list;
    }


    @Override
    public ProductVo getHotProductOne(Integer productID) {
        Product product = productMapper.selectProductByProductID(productID);
        ProductVo hotProductVo = new ProductVo();
        BeanUtils.copyProperties(product,hotProductVo);
        return hotProductVo;
    }

    @Override
    public List<ProductVo> getHotProductPageList() {
        Map<String,Object> map = new HashMap<>();
        map.put("state" , 0 );
        List<ProductVo> list = hotProductMapper.getHotProductPageList(map);
        return list;
    }

    @Override
    public List<ProductViewVo> getPopularRecommendation() {
        Map<String,Object> map = new HashMap<>();
        map.put("state" , 0 );
        List<ProductViewVo> list = hotProductMapper.getPopularRecommendation(map);
        return list;
    }

    @Override
    public boolean saveBatch(Collection<HotProduct> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<HotProduct> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<HotProduct> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(HotProduct entity) {
        return false;
    }

    @Override
    public HotProduct getOne(Wrapper<HotProduct> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<HotProduct> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<HotProduct> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public BaseMapper<HotProduct> getBaseMapper() {
        return null;
    }

    @Override
    public Class<HotProduct> getEntityClass() {
        return null;
    }
}
